(31337_41184546203403, `[large]Overview[/large]

This is an example of a simple assembly definition:
[box][fields]
register
r0 000
r1 001
r2 010
r3 011

[instructions]
mov %a(register), %b(register)
00aaabbb
# Move a value to %a from %b

mov %a(register), %b:U8(immediate)
01000aaa bbbbbbbb
# Move a byte to %a from %b

jmp %a(label)
10000000 aaaaaaaa
# Jump to %a[/box]

Notice the definition is split into two sections [highlight][fields][/highlight] and [highlight][instructions][/highlight].

[large][fields] section[/large]
Fields allow you to give names to bit patterns. This is typically used for registers. More details [link="Assembly/Language creation/Fields"]here[/link].

[large][instructions] section[/large]
Instruction definitions consist of a [color=#66ff99]syntax[/color] line, a [color=#66ccff]machine code[/color] line and a [color=#9966ff]description[/color] line:

[box][color=#66ff99]mov %a(register), %b(register)[/color]
[color=#66ccff]00aaabbb[/color]
[color=#9966ff]# Move a value to %a from %b[/color][/box]
When you type assembly instructions in your language, the assembler will scan this list of definitions, find the first [color=#66ff99]syntax[/color] that matches and produce the corresponding [color=#66ccff]machine code[/color].

[b][color=#66ff99]Syntax line[/color][/b]
The syntax line is a mix of hard coded strings and operands. Operands always start with [highlight]%[/highlight] followed by a name that identifies it on the other lines. Next to this comes an operand field, which can be [highlight]label[/highlight], [highlight]immediate[/highlight] or a custom [highlight]field[/highlight] you defined in the [b][fields][/b] section.

[b][color=#66ccff]Machine code line[/color][/b]
The bitfield line matches [highlight]0[/highlight] or [highlight]1[/highlight] as well as the first letter of any of the operand names defined in the syntax line. [highlight]0[/highlight] and [highlight]1[/highlight] are interpreted literally, while operand letters will use one binary digit at a time from the value of their operand. 

[b][color=#9966ff]Description line[/color][/b]
The description has no function to the assembler, it exists purely for documentation purposes.

The assembler supports a lot more instructions features that you can read about [link="Assembly/Language creation/Instructions"]here[/link].

[large]Other sections[/large]
In addition to [b][fields][/b] and [b][instructions][/b] there are two other optional sections, [b][link="Assembly/Language creation/Settings"][settings][/link][/b] and [b][link="Assembly/Language creation/Patterns"][patterns][/link][/b].

`)